#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import xadmin
from xadmin import views

from . import models


class SKUAdmin(object):
    """SKU的模型站点管理类"""

    model_icon = "fa fa-gift"  # 设置模型在菜单栏显示的小图标

    list_display = ["id", "name", "price", "stock", "sales"]
    search_fields = ['id', 'name']


class BaseSetting(object):
    """xadmin基本配置"""

    enable_themes = True  # 开启主题切换功能
    use_bootswatch = True


class GlobalSettings(object):
    """xadmin的全局配置"""

    site_title = "美多商城运营管理系统"  # 设置站点标题
    site_footer = "美多商城集团有限公司"  # 设置站点的页脚
    menu_style = "accordion"  # 设置菜单折叠


xadmin.site.register(models.GoodsCategory)
xadmin.site.register(models.GoodsChannel)
xadmin.site.register(models.Goods)
xadmin.site.register(models.Brand)
xadmin.site.register(models.GoodsSpecification)
xadmin.site.register(models.SpecificationOption)
xadmin.site.register(models.SKU, SKUAdmin)
xadmin.site.register(models.SKUSpecification)
xadmin.site.register(models.SKUImage)

xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSettings)
